<template>
  <div class="main_spac1">
    <div class="main_white padding10">
      <div class="mainor_form batch-wrap small-top">
        <el-form
          :inline="true"
          :model="form"
          class="demo-form-inline"
          ref="userListFrom"
          label-width="90px"
          id="form"
        >
          <el-form-item label="配送日期：" prop="send_time">
            <el-date-picker
              v-model="form.send_time"
              type="date"
              class="wid220"
              :editable="false"
              placeholder="选择配送日期"
              value-format="yyyy-MM-dd"
              :clearable="false"
              @change="peisonDatePick"
            />
          </el-form-item>
          <el-form-item label="商品：" prop="goods_spu_id">
            <change-goods-input
              ref="changeGoodsInput"
              @clear="clearGoods"
              @sendValue="
                (data) => {
                  this.form.goods_spu_id = data.id;
                  this.getArticleList();
                }
              "
            ></change-goods-input>
          </el-form-item>
          <el-form-item label="用户：" prop="uid">
            <change-user-input
              ref="changeUserInput"
              @sendValue="getUser"
              @clear="clearUid"
              :getFunction="2"
              :time="form.send_time"
              :triggerOnFocus="true"
              @zidname="uidName"
            ></change-user-input>
          </el-form-item>
          <MainFormBtn @reset="reset" @getSearchFor="getSearchFor" :loading="listLoading" :showBtn="moredata">
          </MainFormBtn>
          <div class="more el-form-item" @click="more">
            <span>更多</span>
            <i :class="[{ on: moredata }, ' el-icon-arrow-down']"></i>
          </div>
          <el-collapse-transition>
            <div>
              <div v-show="moredata">
                <el-form-item label="子账号：" prop="zid">
                  <el-select
                    v-model="form.zid"
                    placeholder="子账号"
                    class="wid220"
                    no-data-text
                    filterable
                    @change="getArticleList"
                  >
                    <el-option
                      v-for="(zid_time, index) in zid_name"
                      :key="index"
                      :label="zid_time.nickname"
                      :value="zid_time.id"
                    ></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item label="配送时间：" prop="send_time_id">
                  <el-select
                    v-model.trim="form.send_time_id"
                    placeholder="配送时间"
                    class="wid220"
                    @change="getArticleList"
                  >
                    <el-option label="所有" value="0"></el-option>
                    <el-option
                      v-for="(send_time_list, index) in searchFormData.send_time_list"
                      :key="index"
                      :label="send_time_list"
                      :value="index"
                    ></el-option>
                  </el-select>
                </el-form-item>

                <el-form-item label="商品分类：" prop="category_id" class="wid220">
                  <el-cascader
                    v-model="form.category_id"
                    :options="options"
                    :props="defaultProps"
                    @change="getArticleList"
                  ></el-cascader>
                </el-form-item>

                <el-form-item label="标品：" prop="is_standard">
                  <el-select
                    v-model.trim="form.is_standard"
                    class="wid220"
                    v-model="form.is_standard"
                    @change="getArticleList"
                  >
                    <el-option label="所有" value="0"></el-option>
                    <el-option
                      v-for="(is_standard, index) in searchFormData.is_standardList"
                      :key="index"
                      :label="is_standard"
                      :value="parseInt(index + 1)"
                    ></el-option>
                  </el-select>
                </el-form-item>
                <div class="clearfix"></div>
                <el-form-item label="分拣状态：" prop="sorting">
                  <el-select
                    v-model.trim="form.sorting"
                    class="wid220"
                    @change="getArticleList"
                  >
                    <el-option label="所有" :value="parseInt(0)"></el-option>
                    <el-option
                      v-for="(sortingList, index) in searchFormData.sortingList"
                      :key="index"
                      :label="sortingList"
                      :value="parseInt(index + 1)"
                    ></el-option>
                  </el-select>
                </el-form-item>

                <el-form-item label="配送路线：" prop="line_id">
                  <el-select
                    v-model.trim="form.line_id"
                    placeholder="区域"
                    class="wid220"
                    filterable
                    @change="getArticleList"
                  >
                    <el-option label="所有" :value="parseInt(0)"></el-option>
                    <el-option
                      v-for="(region, index) in searchFormData.line"
                      :key="index"
                      :label="region"
                      :value="index"
                    ></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item label="用户分组：" prop="group_id">
                  <el-select
                    v-model.trim="form.group_id"
                    placeholder="分组"
                    class="wid220"
                    filterable
                    @change="getArticleList"
                  >
                    <el-option label="所有" :value="parseInt(0)"></el-option>
                    <el-option
                      v-for="(group, index) in searchFormData.group"
                      :key="index"
                      :label="group"
                      :value="index"
                    ></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item label="用户区域：" prop="region_id">
                  <el-select
                    v-model.trim="form.region_id"
                    placeholder="区域"
                    class="wid220"
                    filterable
                    @change="getArticleList"
                  >
                    <el-option label="所有" :value="parseInt(0)"></el-option>
                    <el-option
                      v-for="(region, index) in searchFormData.region"
                      :key="index"
                      :label="region"
                      :value="index"
                    ></el-option>
                  </el-select>
                </el-form-item>
                <div class="clearfix"></div>
                <!-- 配送路线   用户分组   用户区域 -->
                <el-form-item label="是否备注：" prop="remark">
                  <el-select
                    v-model="form.remark"
                    filterable
                    class="wid220"
                    @change="getArticleList"
                  >
                    <el-option label="所有" :value="parseInt(0)"></el-option>
                    <el-option
                      v-for="(remarkList, index) in searchFormData.remarkList"
                      :key="index"
                      :label="remarkList"
                      :value="parseInt(index + 1)"
                    ></el-option>
                  </el-select>
                  </el-form-item>
                <el-form-item label="采购员：" prop="buyer">
                  <el-select
                    v-model="form.buyer"
                    filterable
                    class="wid220"
                    @change="getArticleList"
                  >
                    <el-option label="所有" :value="parseInt(0)"></el-option>
                    <el-option
                      v-for="(buyerList, index) in searchFormData.buyerList"
                      :key="index"
                      :label="buyerList"
                      :value="index"
                      filterable
                    ></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item label="供应商：" prop="supplier">
                  <el-select
                    v-model.trim="form.supplier"
                    placeholder="供应商"
                    class="wid220"
                    filterable
                    @change="getArticleList"
                  >
                    <el-option label="所有" :value="parseInt(0)"></el-option>
                    <el-option
                      v-for="(supplierList, index) in searchFormData.supplierList"
                      :key="index"
                      :label="supplierList"
                      :value="index"
                    ></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item label="缺货：" prop="out_status">
                  <el-select
                    v-model.trim="form.out_status"
                    placeholder="缺货"
                    class="wid220"
                    @change="getArticleList"
                  >
                    <el-option label="所有" :value="parseInt(0)"></el-option>
                    <el-option
                      v-for="(outList, index) in searchFormData.outList"
                      :key="index"
                      :label="outList"
                      :value="parseInt(index + 1)"
                    ></el-option>
                  </el-select>
                </el-form-item>
                <div class="clearfix"></div>
                <el-form-item label="预定变更：" prop="modify">
                  <el-select
                    v-model.trim="form.modify"
                    placeholder="预定变更"
                    class="wid220"
                    @change="getArticleList"
                  >
                    <el-option label="所有" value=""></el-option>
                    <el-option label="是" value="1"></el-option>
                    <el-option label="否" value="0"></el-option>
                  </el-select>
                </el-form-item>
                <div class="clearfix"></div>
                <el-form-item label=" ">
                  <MainFormBtn class="btn-bottom" @reset="reset" @getSearchFor="getSearchFor" :loading="listLoading" :showBtn="!moredata">
                  </MainFormBtn>
                </el-form-item>
              </div>
            </div>
          </el-collapse-transition>
        </el-form>
        
      </div>

      <div class="main-controls-wrap">
        <div>
          <el-button @click="sortingAll"
            >分拣全部
            <el-tooltip class="item" effect="dark" placement="bottom">
              <div slot="content">
                系统会把配送日期内所有未分拣商品按下单数量自动完成分拣
              </div>
              <svg
                aria-hidden="true"
                class="navbar_svg new_navbar_svg"
                width="14"
                height="14"
              >
                <use xlink:href="#icon-summary_question" />
              </svg>
            </el-tooltip>
          </el-button>

          <el-button @click="printAll"
            >打印全部
            <el-tooltip class="item" effect="dark" placement="bottom">
              <div slot="content">
                系统会自动把配送日期内所有商品标签连续打印，<br />根据【未分拣打印】配置判断未分拣要不要打印
              </div>
              <svg
                aria-hidden="true"
                class="navbar_svg new_navbar_svg"
                width="14"
                height="14"
              >
                <use xlink:href="#icon-summary_question" />
              </svg>
            </el-tooltip>
          </el-button>

          <el-button @click="chexiaoAll"
            >撤销全部
            <el-tooltip class="item" effect="dark" placement="bottom">
              <div slot="content">
                系统会撤销配送日期内，订单状态为【备货中】所有已分拣商品
              </div>
              <svg
                aria-hidden="true"
                class="navbar_svg new_navbar_svg"
                width="14"
                height="14"
              >
                <use xlink:href="#icon-summary_question" />
              </svg>
            </el-tooltip>
          </el-button>
          <el-button class="marginLeft10" @click="batchSetTime" :disabled="!Boolean(timeIdsList.length)">批量设置日期</el-button>
        </div>
        <div class="batch-wrap-right">
          <el-checkbox
            v-model="not_display_direct_supply_goods"
            @change="
              (val) => {
                checkboxChange(val, 3);
              }
            "
            >不显示直供商品</el-checkbox
          >
          <el-checkbox
            v-model="automatic_printing"
            @change="
              (val) => {
                checkboxChange(val, 1);
              }
            "
            >自动打印</el-checkbox
          >
          <el-tooltip class="item" effect="dark" placement="bottom">
            <div slot="content">
              注释：在使用智能称或手动输入数量并敲回车键完成分拣后，标签自动打印
            </div>
            <svg aria-hidden="true" class="navbar_svg mg-r-10" width="16" height="16">
              <use xlink:href="#icon-summary_question" />
            </svg>
          </el-tooltip>
          <el-checkbox
            v-model="no_sorting_printing"
            @change="
              (val) => {
                checkboxChange(val, 2);
              }
            "
            >未分拣打印</el-checkbox
          >
          <el-tooltip class="item" effect="dark" placement="bottom">
            <div slot="content">注释：勾选后，未分拣商品也可打印</div>
            <svg aria-hidden="true" class="navbar_svg" width="16" height="16">
              <use xlink:href="#icon-summary_question" />
            </svg>
          </el-tooltip>
        </div>
      </div>
      <div class="main_table">
        <el-table
          ref="multipleTable"
          v-loading="listLoading"
          :data="tableList"
          element-loading-text="加载中"
          fit
          highlight-current-row
          border
          :row-class-name="cellStyle"
          :header-cell-class-name="this.$verticaline"
          :height="borderHeight"
          :header-cell-style="tableHeightStyle"
          @header-dragend="changeTableWidth"
          @sort-change="tableSortChange"
          shwo
          @selection-change="handleSelectionChange"
        >
          <el-table-column type="selection" width="55" :selectable="selectable"></el-table-column>
          <el-table-column
            label="序号"
            fixed
            prop="userId"
            :width="tableWidth[hash + 'userId'] || 80"
          >
            <template slot-scope="scope">{{
              (current.page - 1) * current.per_page + scope.$index + 1
            }}</template>
          </el-table-column>
          <div v-for="(field, index) in field" :key="index">
            <el-table-column
              label="用户"
              sortable="custom"
              prop="childname"
              :min-width="tableWidth[hash + 'childname'] || 120"
              v-if="field == 1"
            >
              <template slot-scope="scope">
                <div v-show="scope.row.labels.length > 0">
                  <el-popover
                    placement="bottom-start"
                    width="200"
                    trigger="hover"
                  >
                    <div class="item-label">
                      <span v-for="item in scope.row.labels" :key="item">
                        <div>{{ labels[item] }}</div>
                      </span>
                    </div>
                    <img
                      slot="reference"
                      class="label-pic"
                      src="../../assets/images/10.png"
                    />
                  </el-popover>
                </div>
                <span>{{ scope.row.childname }}</span>
              </template>
            </el-table-column>
            <el-table-column
              label="用户编码"
              prop="usercode"
              :width="tableWidth[hash + 'uesrcode'] || 100"
              v-if="field == 2"
            />
            <el-table-column
              label="用户临时编码"
              prop="code"
              :width="tableWidth[hash + 'code'] || 120"
              v-if="field == 3"
            />
            <el-table-column
              label="配送路线"
              prop="line_id"
              :width="tableWidth[hash + 'line_id'] || 110"
              v-if="field == 15"
            >
              <template slot-scope="scope">
                {{ lineType(scope.row.order.line_id) }}
              </template>
            </el-table-column>
            <el-table-column
              label="商品名称"
              prop="spu_name"
              :width="tableWidth[hash + 'spu_name'] || 150"
              v-if="field == 4"
            >
              <template slot-scope="scope">
                <span
                  style="color: #03a98e"
                  v-show="scope.row.purchase_mode == 3 ? true : false"
                  >【直】</span
                >
                <span
                  style="color: #e6a23c"
                  v-show="scope.row.out_status == 1 ? true : false"
                  >【缺】</span
                >

                <span
                  v-show="scope.row.modify == 1 ? true : false"
                  style="color: red"
                >
                  【更】
                </span>

                {{ scope.row.name }}【{{ scope.row.spu_name }}】
              </template>
            </el-table-column>
            <el-table-column
              label="下单数量"
              prop="order_num"
              :width="tableWidth[hash + 'order_num'] || 120"
              v-if="field == 5"
            >
              <template slot-scope="{ row }">
                {{
                  row.base_order_num
                    ? row.base_order_num
                    : row.order_num + " " + row.spu_name
                }}
              </template>
            </el-table-column>
            <el-table-column
              label="分拣数量"
              prop="sort_num"
              sortable="custom"
              :min-width="tableWidth[hash + 'sort_num'] || 150"
              class-name="main_hei"
              v-if="field == 6"
            >
              <template slot-scope="scope">
                <el-input
                  :ref="'sorting' + scope.$index"
                  v-model="scope.row.sort_num"
                  :disabled="scope.row.disabled"
                  placeholder=""
                  class="wid120"
                  @focus="inputFocus(scope, $event)"
                  @blur="inputBlur(scope, $event)"
                  @keyup.enter.native="nextFocus(scope, $event, 0)"
                ></el-input>
              </template>
              <!-- @change="
                    (val) => {
                      fenjiancount(val, scope);
                    }
                  " -->
            </el-table-column>
            <el-table-column
              label="分拣单位"
              prop="unit"
              :width="tableWidth[hash + 'unit'] || 120"
              v-if="field == 7"
            />
            <el-table-column
              label="生产日期"
              prop="mfg"
              :width="tableWidth[hash + 'mfg'] || 150"
              class-name="main_hei"
              v-if="field == 8"
            >
              <template slot-scope="scope">
                <el-date-picker
                  v-model="scope.row.mfg"
                  type="date"
                  class="wid120"
                  :editable="false"
                  value-format="yyyy-MM-dd"
                  :clearable="false"
                  :disabled="scope.row.dateDisabled"
                  @change="
                    (val) => {
                      fenjiantime(val, scope);
                    }
                  "
                />
              </template>
            </el-table-column>
            <el-table-column
              label="库存"
              v-if="field == 9"
              prop="inventory_num"
              :width="tableWidth[hash + 'inventory_num'] || 120"
            >
              <template slot-scope="scope">{{
                scope.row.goods_spu.inventory
                  ? scope.row.goods_spu.inventory.num
                  : ""
              }}</template>
            </el-table-column>
            <el-table-column
              label="库存单价"
              prop="goods_spu.inventory.price"
              :width="tableWidth[hash + 'goods_spu.inventory.price'] || 120"
              v-if="field == 10"
            />
            <el-table-column
              label="分拣状态"
              :width="tableWidth[hash + 'status'] || 120"
              prop="status"
              v-if="field == 11"
            >
              <template slot-scope="scope">
                <div class="main_link">
                  <el-link type="danger" v-if="scope.row.status == 0"
                    >未分拣</el-link
                  >
                  <el-link type="success" v-else>已分拣</el-link>
                </div>
              </template>
            </el-table-column>
            <el-table-column
              label="备注"
              prop="remark"
              :width="tableWidth[hash + 'remark']"
              v-if="field == 12"
            />
            <el-table-column
              label="分拣员"
              prop="sort_uid"
              :width="tableWidth[hash + 'sort_uid'] || 120"
              v-if="field == 13"
            >
              <template slot-scope="scope">
                {{ sort_user[scope.row.sort_uid] }}
              </template>
            </el-table-column>
            <el-table-column
              label="分拣时间"
              prop="sort_time"
              :width="tableWidth[hash + 'sort_time'] || 120"
              v-if="field == 14"
            >
              <template slot-scope="scope">{{
                scope.row.sort_time
                  ? parseTime(scope.row.sort_time, "{y}-{m}-{d}")
                  : ""
              }}</template>
            </el-table-column>
            <el-table-column
              label="配送单价"
              prop="sort_price"
              sortable="custom"
              :width="tableWidth[hash + 'sort_price'] || 120"
              v-if="field == 16"
            >
            </el-table-column>
          </div>
          <el-table-column
            label="管理操作"
            align="left"
            fixed="right"
            prop="operate"
            :width="tableWidth[hash + 'operate'] || 200"
            class-name="main_hei"
          >
            <template slot="header">
              <table-header-setting
                @openHeader="dialogFormVisible = true"
              ></table-header-setting>
            </template>
            <template slot-scope="scope">
              <el-link
                v-if="scope.row.order.order_status == 1 ? true : false"
                type="success"
                @click="accumu(scope)"
                >累加</el-link
              >

              <span
                slot="reference"
                v-if="scope.row.order.order_status == 1 ? true : false"
                ><el-link
                  type="warning"
                  v-if="scope.row.status == 0"
                  @click="quehuo(scope.row.id, scope)"
                  >缺货</el-link
                ></span
              >

              <!-- <el-link
                type="primary"
                v-if="scope.row.status == 1"
                @click="xiugaiMethod(scope)"
                >修改</el-link
              > -->

              <span v-if="scope.row.order.order_status == 1 ? true : false">
                <el-link
                  type="danger"
                  v-if="scope.row.status == 1"
                  @click="chexiaoMethod(scope.row.id, scope)"
                  >撤销</el-link
                >
              </span>
              <el-link
                @click="print(scope.row.id)"
                v-if="scope.row.status == 1 || no_sorting_printing"
                >打印</el-link
              >
            </template></el-table-column
          >
        </el-table>
      </div>
      <div class="main_num boxdq">
        <div class="main_num_l box">
          <div class="mainsu_te marginRight5"></div>
          <p>
            总分拣单元：
            <em>{{ sort_arr_list.count || 0 }}</em>
          </p>
          <p>
            已分拣单元：
            <em>{{ sort_arr_list.over_count || 0 }}</em>
          </p>
          <p>
            未分拣单元：
            <em>{{ weifenjian_count || 0 }}</em>
          </p>
          <p>
            缺货单元：
            <em>{{ sort_arr_list.que_count || 0 }}</em>
          </p>
          <p>
            预定总量：
            <em>{{ order_num_all || 0 }}</em>
          </p>
          <p>
            分拣总量：
            <em>{{ sort_num_all || 0 }}</em>
          </p>

          <p class="box" style="width: 400px; align-items: center">
            分拣进度：
            <el-progress
              :text-inside="true"
              :stroke-width="14"
              :percentage="fenjian_percent"
              status="success"
              color="#E47C02"
              style="width: 60%"
            ></el-progress>
          </p>
        </div>
        <!-- 分页 -->
        <div class="main_page_r">
          <MainPagination
            :current-page="current.page"
            :page-sizes="[100, 200, 300]"
            :page-size="limit"
            layout="total, sizes, prev, pager, next, jumper"
            :total="totalCount"
            background
            @size-change="changeLimit"
            @current-change="changePage"
          />
        </div>
      </div>
    </div>

    <!-- 表头设置 -->
    <el-dialog
      title="表头设置"
      :visible.sync="dialogFormVisible"
      class="main_dialog dialog500"
      @close="type = field"
    >
      <div class="set_sort">
        <div class="set_none_show">
          <el-checkbox-group v-model="type">
            <el-checkbox
              v-for="(Header, index) in Header"
              :key="index"
              :label="Header.id"
              :disabled="Header.disabled"
              >{{ Header.name }}</el-checkbox
            >
          </el-checkbox-group>
        </div>
        <div class="set_header_sort">
          <div class="set_sort_ab">
            <draggable chosen-class="chosen" v-model="Header" animation="500">
              <transition-group>
                <li
                  class="set_sort_ab_border"
                  v-for="item in Header"
                  :key="item.id"
                >
                  <div>
                    <span class="el-icon-d-caret"></span>
                    <span>{{ item.name }}</span>
                  </div>
                  <svg-icon icon-class="index_move" />
                </li>
              </transition-group>
            </draggable>
          </div>
        </div>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取 消</el-button>
        <el-button type="primary" @click="setupmine" v-repeatClick
          >确 定</el-button
        >
      </div>
    </el-dialog>
    <!-- 累加分拣弹出窗 -->
    <el-dialog
      title="累加分拣"
      :visible.sync="addDialogFormVisible"
      width="30%"
    >
      <div class="dialog_padding20_30">
        <el-form :model="form" @submit.native.prevent>
          <el-form-item label="下单数量：" label-width="120px" class="addfenjian">
            <span class="add_num">{{ addInfo.order_num }}</span>
          </el-form-item>
          <el-form-item label="已分拣数量：" label-width="120px" class="addfenjian">
            <span class="add_num">{{ addInfo.sort_num }}</span>
          </el-form-item>
          <el-form-item label="分拣数量：" label-width="120px" class="addfenjian">
            <el-input
              v-model.trim="addInfo.new_num"
              autocomplete="off"
              placeholder="智能称或输入数量后回车"
              size="medium"
              autofocus="true"
              type="number"
              ref="addInfoInput"
              @keyup.enter.native="countadd(1)"
            ></el-input>
          </el-form-item>
          <el-form-item label="是否分次打印：" label-width="120px">
            <el-tooltip
              class="item"
              effect="dark"
              content="勾选后，每次累加数量都会打印标签"
              placement="bottom"
            >
              <i class="el-icon-question icon" style="padding-rigth: 30px"></i>
            </el-tooltip>
            <el-switch
              v-model="isPrint"
              active-text="开"
              inactive-text="关"
              active-color="#03A98E"
              class="mainor_switch"
              style="margin-left: 20px"
            ></el-switch>
          </el-form-item>
          <el-form-item label="累加明细：" label-width="120px">
            <el-tag
              size="mini"
              v-for="(item, index) in addInfo.numhistory"
              style="margin-right: 8px"
              :key="index"
              >{{ item }}</el-tag
            >
          </el-form-item>
          <el-form-item label="本次分拣数量：" label-width="120px" class="addfenjian">
            <span class="add_num">{{ addInfo.add_sum }}</span>
          </el-form-item>
        </el-form>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="accountComplete">完 成</el-button>
        <el-button @click="addDialogFormVisible = false">取 消</el-button>
      </div>
    </el-dialog>

    <!--订单导出  -->
    <el-dialog title="订单导出" :visible.sync="dingdanvisiable" width="30%">
      <div>
        <p>选择导出时间</p>
        <div>
          <el-date-picker
            v-model="value1"
            type="daterange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
          >
          </el-date-picker>
          <el-select v-model="value" placeholder="请选择">
            <el-option
              v-for="item in options"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
          <el-tooltip
            class="item"
            effect="dark"
            content="Top Left 提示文字"
            placement="top-start"
          >
            <i class="el-icon-question"></i>
          </el-tooltip>
        </div>
      </div>
      <div>
        <p>选择导出字段</p>
        <el-checkbox-group v-model="type">
          <el-checkbox
            v-for="(Header, index) in Header"
            :key="index"
            :label="Header.id"
            :disabled="Header.disabled"
            >{{ Header.name }}</el-checkbox
          >
        </el-checkbox-group>
      </div>
    </el-dialog>
    <!-- 打印子组件 -->
    <sort-note-print
      ref="printTemplate"
      v-show="false"
      id="printname"
    ></sort-note-print>
    <!--批量设置生成日期  -->
    <el-dialog title="批量设置生成日期" :visible.sync="timeIdsShow" width="30%">
      <div class="batch-time-wrap">
        <el-form :model="timeForm" :rules="timeFormRules" ref="timeFormRef">
          <el-form-item label="生产日期：" label-width="120px" class="addfenjian" prop="mfg">
            <el-date-picker
              v-model="timeForm.mfg"
              type="date"
              class="wid220"
              :clearable="false"
              value-format="yyyy-MM-dd"
            />
          </el-form-item>
        </el-form>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="timeIdsShow = false">取 消</el-button>
        <el-button type="primary" @click="submitBatchTime" v-repeatClick>确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { mixins } from "@/mixins/index.js";
import {
  sorting_accumulation,
  sorting_stock,
  sorting_revoke,
  sorting_add,
  sort_list,
  revoke_list,
  sorting_add_time,
  sorting_indexAll,
  sorting_searchAll,
  batch_add_time
} from "@/api/sorting/sortingStart";
import { field_getField } from "@/api/sort";
import { apiUrl, objKeySort, Md5, packApi } from "@/utils/public";
import { recursion, category } from "@/utils/index";
import { field_save, setting_company } from "@/api/currency";
import { parseTime } from "@/utils/index";
import SortNotePrint from "@/views/sorting/sortPrintNote.vue";
import { sortingOneHeader } from "@/options/headerSet";
import { mapGetters } from "vuex";
import draggable from "vuedraggable";
import { user_getMemberInfo } from "@/api/currency";
export default {
  mixins: [mixins],
  components: {
    SortNotePrint,
    draggable,
  },
  data() {
    return {
      order_num_all: 0,
      sort_num_all: 0,
      // 时间
      parseTime,
      // 分页
      current: {
        page: 1,
        per_page: 100,
      },
      rowindex: "",
      // 订单弹出框开始
      dingdanvisiable: false,
      value1: "",
      value: "",
      // 订单弹出框结束
      limit: 100,
      totalCount: 1,
      // 更多
      moredata: false,
      // 总分拣单元 统计
      sort_arr_list: {
        count: 0,
        over_count: 0,
        qeu_count: 0,
        que_count: 0,
      },
      // 弹出层默认绑定的打印
      radio: "1",
      // 是否分次打印
      isPrint: false,
      // 累加操作的信息

      addInfo: {
        id: "",
        num: "", //原始数据
        numhistory: [], //添加的记录
        new_num: "", //添加数据
        order_num: "", //下单数量
        sort_num: "0", //分拣数量
        add_sum: 0, //本次分拣的和
      },
      // 搜索
      form: {
        pid: "",
        category_id: [],
        goods_spu_id: "", //商品名称
        uid: "", //商户名称
        send_time: parseTime(new Date(), "{y}-{m}-{d}"), //配送日期
        send_time_id: "0", //配送时间
        goods_type_list: "", //商品分类
        is_standard: "0", //标品
        sorting: 0, //分拣状态
        remark: 0, //是否备注
        buyer: 0, //采购员
        supplier: 0, //供应商
        out_status: 0,
        line_id: 0, //用户路线
        group_id: 0, //用户分组
        region_id: 0, //用户区域
        modify: "", //预定变更
        zid: "",
        childname: null, // 用户排序
        sort_num: null, // 分拣数量排序
        sort_price: null, // 配送单价排序
      },
      zid_name: [],
      low_stocks: false,
      usable_stock: false,
      calculate_losses: false,
      automatic_printing: false,
      no_sorting_printing: false,
      not_display_direct_supply_goods: true,
      // 列表数据
      list: {
        arr: {},
        list: [],
      },
      // 表格数据
      tableList: [],
      // 搜索数据
      searchFormData: {},
      // 分拣全部-撤销全部-打印全部
      // 分拣员
      sort_user: {},
      // 用户标签
      labels: {},
      // 表头设置列表
      field: {},
      listLoading: false,
      // 表头设置
      dialogFormVisible: false,
      // 累加弹出窗
      addDialogFormVisible: false,
      type: [],
      Header: sortingOneHeader,
      // 分类
      options: [],
      defaultProps: {
        children: "selfNext",
        label: "title",
        value: "id",
        checkStrictly: true,
      },
      // 累加时当前行的数据
      accumulation_row: {},
      lines: {},
      moredata: false,
      timeIdsShow: false, //  批量设置日期弹窗
      timeIdsList: [], //  批量设置日期id
      timeForm: {      //  批量设置日期时间
        mfg: ""
      },
      timeFormRules: {
        mfg: [
          { required: true, message: '生产日期不能为空', trigger: 'change' },
        ]
      }
    };
  },
  computed: {
    ...mapGetters(["userInfo"]),
    // 未分拣单元
    weifenjian_count() {
      return this.sort_arr_list.count - this.sort_arr_list.over_count;
    },

    // 分拣经度进度
    fenjian_percent() {
      let percent = 0;
      if (this.sort_arr_list.count == 0) {
        percent = 0;
      } else {
        percent =
          (this.sort_arr_list.over_count / this.sort_arr_list.count) * 100;
      }
      percent = Math.round(percent);
      return percent;
    },
    lineType() {
      return function (siteType) {
        return this.lines[siteType];
      };
    },
  },
  created() {
    if (this.$route.params.sorting) {
      this.form.sorting = this.$route.params.sorting;
    }
    this.getNumerical(190);
    // 列表
    this.getSearchForm();
    this.getList();
  },
  mounted() {
    this.sort_data();
  },
  // 刷新
  inject: ["reload"],
  methods: {
    //  打开批量设置生成日期弹窗
    batchSetTime() {
      this.timeIdsShow = true
      this.timeForm.mfg = ''
    },
    //  根据每一列的dateDisabled去判断是否可选
    selectable(row) {
      return !row.dateDisabled
    },
    //  表格切换选中列
    handleSelectionChange(val) {
      this.timeIdsList = val.map(el => el.id)
    },
    getSearchFor() {
      this.getArticleList();
    },
    //  批量设置时间
    submitBatchTime() {
      this.$refs.timeFormRef.validate((valid) => {
        if (valid) {
          batch_add_time(packApi({
            ids: this.timeIdsList,
            mfg: this.timeForm.mfg
          })).then(res => {
            if(res.errcode == 0) {
              this.timeIdsShow = false
              this.$message.success('设置成功')
              this.getList();
            }else {
              this.$message.error(res.errmsg)
            }
          })
        }
      });
    },
    //排序
    sort_data() {
      let data = packApi({ type: 8 });
      field_getField(data).then((res) => {
        let arry = JSON.parse(res.data.info.sort);
        if (arry || arry.length) {
          this.Header.sort((a, b) => {
            return arry.indexOf(a.id) - arry.indexOf(b.id);
          });
        }
        // 在数据更新后执行
        this.$nextTick(() => {
          // myTable是表格的ref属性值
          if (this.$refs.multipleTable && this.$refs.multipleTable.doLayout) {
            this.$refs.multipleTable.doLayout();
          }
        });
      });
    },
    //获取用户信息
    getUser(data) {
      let uid = data.info.user_id;
      this.form.uid = uid;
      this.getList();
    },
    // 清除用户的uid
    clearUid() {
      this.form.uid = "";
      this.form.zid = "";
      this.zid_name = [];
    },
    //展示子账号
    uidName(uid) {
      let data = Object.assign(
        {
          sign: Md5(
            objKeySort(Object.assign(apiUrl().name)) + apiUrl().appsecret
          ),
        },
        apiUrl().name,
        { id: uid }
      );
      user_getMemberInfo(data).then((res) => {
        if (res.errcode == 0) {
          this.form.zid = "";
          this.form.zid_name = null;
          res.data.subAccount.map((e, ind) => {
            if (ind == 0) {
              e.id = 0;
              e.nickname = "主账号";
            }
          });
          res.data.subAccount.unshift({
            id: "",
            nickname: "所有",
          });
          this.zid_name = res.data.subAccount;
        } else {
          this.$message.error(res.errmsg);
        }
      });
    },
    // 单元格的 style 的回调方法
    cellStyle({ row, rowIndex }) {
      if (rowIndex === this.rowindex) {
        return "success";
      } else {
        return;
      }
    },
    // 点击排序
    tableSortChange({column, prop, order}) {
      this.form.childname = null;
      this.form.sort_num = null;
      this.form.sort_price = null;
      this.form[prop] = order;
      this.getList();
    },
    // 搜索勾选
    checkboxChange(val, type) {
      let parmas = {};
      if (type == 1) {
        parmas.automatic_printing = val ? 1 : 0;
      } else if (type == 2) {
        parmas.no_sorting_printing = val ? 1 : 0;
      } else if (type == 3) {
        parmas.not_display_direct_supply_goods = val ? 1 : 0;
      }
      let data = packApi(parmas);
      setting_company(data).then((res) => {
        if (res.errcode == 0) {
          if (type == 3) {
            this.getArticleList();
          }
        } else {
        }
      });
    },
    // 更多
    more() {
      this.moredata = !this.moredata;
    },
    // 累加框展示
    accumu(value) {
      let res = value.row;
      this.accumulation_row = value;
      this.addInfo.id = res.id;
      this.addInfo.num = res.sort_num;
      this.addInfo.order_num = res.order_num;
      this.addInfo.sum = 0;
      this.addInfo.sort_num = 0;
      this.addInfo.add_sum = 0;
      if (res.sort_num) {
        this.addInfo.sort_num = res.sort_num;
      }

      this.addInfo.numhistory = [];
      this.addDialogFormVisible = true;
      this.$nextTick(() => {
        this.$refs["addInfoInput"].focus();
      });
    },
    // 累加回车事件
    countadd(value) {
      if (this.addInfo.new_num == "") {
        return;
      }
      this.addInfo.num =
        parseFloat(this.addInfo.num) + parseFloat(this.addInfo.new_num);
      this.addInfo.numhistory.push(this.addInfo.new_num);
      if (this.isPrint) {
        this.print(this.addInfo.id, this.addInfo.new_num);
      }
      if (this.addInfo.new_num) {
        this.addInfo.add_sum += parseFloat(this.addInfo.new_num);
      }

      this.addInfo.new_num = "";
    },

    // 累加完成事件
    accountComplete() {
      if (this.addInfo.add_sum) {
        let scope = this.accumulation_row;
        let index = scope.$index;
        let newindex = index + 1;
        scope.row.disabled = true;
        scope.row.status = 1;
        let sort_num = 0;

        if (scope.row.sort_num) {
          sort_num = scope.row.sort_num;
        }
        scope.row.sort_num =
          parseFloat(sort_num) + parseFloat(this.addInfo.add_sum);

        this.$nextTick(() => {
          this.addDialogFormVisible = false;
          if (this.$refs["sorting" + newindex]) {
            this.$refs["sorting" + newindex][0].focus();
          }
        });
        this.sorting_accumulation(this.addInfo.add_sum)
          .then((res) => {
            if (res.errcode == 0) {
              if (this.addInfo.add_sum == 0) {
                this.sort_arr_list.over_count += 1;
                this.sort_arr_list.que_count += 1;
              } else {
                this.sort_arr_list.over_count += 1;
                this.sort_num_all = this.$toFixed(
                  +this.sort_num_all + +this.addInfo.add_sum
                );
              }
            }
          })
          .catch(() => {
            this.getList();
          });
      }
    },
    // input框聚焦时
    inputFocus(scope, $event) {
      this.rowindex = scope.$index;
      scope.row.sort_num = "";
    },
    // 失去焦点
    inputBlur(scope, $event) {
      this.rowindex = -1;
    },
    // 焦点离开商品分类demo
    nextFocus(scope, $event, status) {
      let id = scope.row.id;
      let index = scope.$index;
      let val = $event.target.value;
      let newindex = index + 1;
      if (/^(\d+\.?)?\d{0,2}$/.test(parseFloat(val)) && val != "") {
        $event.target.blur();
        let parmas = {
          id: id,
          num: val,
          status,
        };
        if (val == 0) {
          scope.row.out_status = 1;
        }
        scope.row.disabled = true;
        scope.row.status = 1;
        this.xiugai(parmas).then((res) => {
          if (res.errcode == 40202) {
            this.$confirm(res.errmsg + "，是否保存？", "提示", {
              type: "warning",
            })
              .then(() => {
                this.nextFocus(scope, $event, 1);
              })
              .catch(() => {
                scope.row.disabled = false;
                scope.row.status = 0;
                this.$nextTick(() => {
                  this.$refs["sorting" + index][0].focus();
                });
              });
          } else {
            if (res.errcode == 0) {
              if (val == 0) {
                this.sort_arr_list.over_count += 1;
                this.sort_arr_list.que_count += 1;
              } else {
                this.sort_arr_list.over_count += 1;
                this.sort_num_all = this.$toFixed(+this.sort_num_all + +val);
              }
            }
            if (res.errcode == 0 && this.automatic_printing) {
              this.print(scope.row.id);
            }
            if (res.errcode != 0) {
              this.getList();
              this.$message.error(res.errmsg);
            }
          }
          if (this.$refs["sorting" + newindex]) {
            this.$refs["sorting" + newindex][0].focus();
          }
        });
      } else {
        this.$message.warning("请输入正确的数字订单");
        $event.target.value = "";
      }
    },
    // 订购数量？注释
    renderHeader(h, { column, $index }) {
      // 这里在最外层插入一个div标签
      return h("div", [
        // h即为cerateElement的简写
        // 在div里面插入span
        h("span", {
          // 表示内容
          domProps: {
            innerHTML: column.label,
          },
          on: {
            click: () => {
              console.log(`${column.label}   ${$index}`);
            },
          },
        }),
        h(
          "el-tooltip",
          {
            // 表示属性
            attrs: {
              effect: "dark",
              content: "所有档口下单数量的总和！",
              placement: "top",
            },
          },
          [
            h("i", {
              style: "margin-left: 5px;margin-top:-1px;",
              class: "el-icon-question table-msg",
            }),
          ]
        ),
      ]);
    },
    clearGoods() {
      this.form.goods_spu_id = "";
    },
    // 搜索
    getArticleList() {
      this.current.page = 1;
      this.getList();
    },
    // 重置
    reset() {
      this.$refs["userListFrom"].resetFields(),
        (this.createTime = []),
        (this.establishTime = []),
        (this.$refs["changeGoodsInput"].name = "");
      this.form.uid = "";
      this.$refs["changeUserInput"].name = "";
      this.getList();
    },
    // 分页
    changeLimit(pageSize) {
      this.current.per_page = pageSize;
      this.getList();
    },
    changePage(page) {
      this.current.page = page;
      this.getList();
    },
    // 设置确认
    setupmine(val) {
      let arry = [];
      let arrys = [];
      this.Header.map((e) => {
        arrys.push(e.id);
        this.type.map((p) => {
          if (e.id == p) {
            arry.push(e.id);
            return;
          }
        });
      });
      let data = Object.assign(
        {
          sign: Md5(
            objKeySort(Object.assign(apiUrl().name, { type: 8 })) +
              apiUrl().appsecret
          ),
        },
        apiUrl().name,
        { type: 8, fields: JSON.stringify(arry), sort: JSON.stringify(arrys) }
      );
      field_save(data).then((res) => {
        if (res.errcode == 0) {
          this.$message({
            message: "设置成功",
            type: "success",
          });
          // this.reload();
          this.getList();
        } else {
          this.$message.error(res.errmsg);
        }
      });
      this.dialogFormVisible = false;
    },
    // 列表
    getList() {
      this.listLoading = true;
      let data = packApi({
        ...this.list_form(),
        ...this.current,
      });
      sorting_indexAll(data).then(res=> {
        this.listLoading = false;
        if (res.errcode == 0) {
          this.tableList = res.data.arr.list.map((e) => {
            e.usercode = e.member.info.code;
            e.cursor = false;
            e.childname = e.hasOwnProperty("newname") ? e.newname : e.member.nickname;
            if (e.status == 0 && (e.sort_num === 0.0 || e.sort_num)) {
              e.sort_num = "";
            }
            if (e.order.order_status != 1) {
              e.disabled = true;
              e.dateDisabled = true;
            } else {
              e.disabled = e.status == 0 ? false : true;
              e.dateDisabled = false;
            }
            // 标签
            e.labels = [];
            if (e.member.info && e.member.info.labels) {
              e.labels = e.member.info.labels.filter((s) => {
                return s && s.trim();
              });
            }
            return e;
            // 结束
          });
          this.labels = res.data.arr.labels;
          this.sort_arr_list = res.data.arr.sort_arr_list;
          this.order_num_all = this.$toFixed(res.data.arr.order_num_all);
          this.sort_num_all = this.$toFixed(res.data.arr.sort_num_all);
          this.totalCount = res.data.arr.page.count;
          this.type = res.data.arr.field;
          this.field = res.data.arr.field;
          // 在数据更新后执行
          this.$nextTick(() => {
            // myTable是表格的ref属性值
            if (this.$refs.multipleTable && this.$refs.multipleTable.doLayout) {
              this.$refs.multipleTable.doLayout();
            }
          });
        }else {
          this.$message.error(res.errmsg);
        }
      });
    },
    // 获取搜索条件
    getSearchForm() {
      sorting_searchAll(packApi()).then((res)=> {
        if(res.errcode == 0) {
          this.searchFormData = res.data;
          this.lines = res.data.line;
          this.automatic_printing = res.data.automatic_printing == 1 ? true : false;
          this.not_display_direct_supply_goods = res.data.not_display_direct_supply_goods == 1 ? true : false;
          this.no_sorting_printing = res.data.no_sorting_printing == 1 ? true : false;
          this.sort_user = res.data.sort_user;
          this.options = recursion(res.data.goods_type_list, true);
        }else {
          this.$message.error(res.errmsg);
        }
      })
    },

    list_form() {
      let form = JSON.parse(JSON.stringify(this.form));
      form.pid = form.category_id[0] ? form.category_id[0] : "";
      form.category_id = category(form.category_id);
      return form;
    },
    // 商品累计添加
    sorting_accumulation(val) {
      let data = Object.assign(
        {
          sign: Md5(
            objKeySort(Object.assign(apiUrl().name) + apiUrl().appsecret)
          ),
        },
        { id: this.addInfo.id, num: val }
      );
      return new Promise((resolve, reject) => {
        sorting_accumulation(data).then((res) => {
          if (res.errcode !== 0) {
            reject();
            this.$message.error("添加失败，请重试");
          } else {
            resolve();
          }
        });
      });
    },
    // 分拣缺货
    quehuo(id, scope) {
      this.$confirm("您确定对该商品进行缺货备注吗？ ", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          let data = Object.assign(
            {
              sign: Md5(
                objKeySort(Object.assign(apiUrl().name) + apiUrl().appsecret)
              ),
            },
            { id: id }
          );

          let row = scope.row;
          let index = scope.$index;
          let newindex = index + 1;
          sorting_stock(data).then((res) => {
            if (res.errcode == 0) {
              this.$message.success("提交成功");
              row.out_status = 1;
              row.status = 1;
              row.sort_time = new Date();
              row.sort_num = 0;
              row.sort_uid = this.userInfo.id;
              if (row.order_status != 1) {
                row.disabled = true;
                row.dateDisabled = true;
              } else {
                row.disabled = row.status == 0 ? false : true;
                row.dateDisabled = false;
              }
              if (this.$refs["sorting" + newindex]) {
                this.$refs["sorting" + newindex][0].focus();
              }
              this.sort_arr_list.over_count += 1;
              this.sort_arr_list.que_count += 1;
            } else {
              this.$message.error(res.errmsg);
            }
          });
        })
        .catch(() => {});
    },
    chexiaoMethod(id, scope) {
      this.$confirm("将撤销该分拣商品, 是否确定?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.chexiao(id, scope);
        })
        .catch(() => {});
    },
    // 分拣撤销
    chexiao(id, scope) {
      let data = Object.assign(
        {
          sign: Md5(
            objKeySort(Object.assign(apiUrl().name) + apiUrl().appsecret)
          ),
        },
        { id: id }
      );

      let row = scope.row;
      let status = row.status;
      let out_status = row.out_status;
      let index = scope.$index;
      let newindex = index + 1;
      sorting_revoke(data).then((res) => {
        if (res.errcode == 0) {
          this.$message.success("商品撤销成功");
          this.sort_num_all = this.$toFixed(+this.sort_num_all - +row.sort_num);
          row.modify = 0;
          row.out_status = 0;
          row.sort_uid = 0;
          row.sort_time = 0;
          row.status = 0;
          row.sort_num = 0;
          row.mfg = "";
          row.inventory_price = "";
          if (row.status == 0) {
            if (row.sort_num == 0.0 || row.sort_num) {
              row.sort_num = "";
            }
          }
          if (row.order.order_status != 1) {
            row.disabled = true;
            row.dateDisabled = true;
          } else {
            row.disabled = row.status == 0 ? false : true;
            row.dateDisabled = false;
          }

          this.sort_arr_list.over_count -= 1;
          if (status == 1 && out_status == 1) {
            this.sort_arr_list.que_count -= 1;
          }

          this.$nextTick(() => {
            if (this.$refs["sorting" + index]) {
              this.$refs["sorting" + index][0].focus();
            }
          });
        } else {
          this.$message.error(res.errmsg);
        }
      });
    },
    // 分拣修改请求
    xiugai(params) {
      let data = Object.assign(
        {
          sign: Md5(
            objKeySort(Object.assign(apiUrl().name) + apiUrl().appsecret)
          ),
        },
        params
      );
      return new Promise((reslove, reject) => {
        sorting_add(data)
          .then((res) => {
            reslove(res);
          })
          .catch((err) => {
            reject(err);
          });
      });
    },

    // 生产日期修改
    fenjiantime(val, scope) {
      let id = scope.row.id;
      let params = {
        id: id,
        mfg: val,
      };
      let data = Object.assign(
        {
          sign: Md5(
            objKeySort(Object.assign(apiUrl().name) + apiUrl().appsecret)
          ),
        },
        params
      );
      sorting_add_time(data).then((res) => {});
    },
    // 分拣修改事件
    xiugaiMethod(scope) {
      scope.row.disabled = !scope.row.disabled;
    },

    //分拣全部
    sortingAll() {
      let goodsList = this.tableList;
      let newList = [];
      goodsList.forEach((item) => {
        if (item && item.status == 0) {
          newList.push(item.id);
        }
      });

      this.$confirm(
        `系统将自动分拣 ${newList.length}个商品，确定吗？`,
        "提示",
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }
      )
        .then(() => {
          if (newList.length == 0) {
            this.$message.warning("没有需要操作的商品");
            return;
          }
          let ids = newList.join("-");
          let data = Object.assign(
            {
              sign: Md5(
                objKeySort(Object.assign(apiUrl().name, { ids: ids })) +
                  apiUrl().appsecret
              ),
            },
            apiUrl().name,
            { ids: ids }
          );
          this.listLoading = true;
          sort_list(data).then((res) => {
            if (res.errcode == 0) {
              this.$message.success("分拣成功");
              this.listLoading = false;
              // this.reload();
              this.getList();
            } else if (res.errcode == 50155) {
              this.$message.error(`${res.errmsg}`);
              setTimeout(() => {
                this.getArticleList();
              }, 1000);
            } else {
              this.$message.error("全部分拣失败");
            }
          });
        })
        .catch(() => {});
    },
    // 打印全部
    printAll() {
      let goodsList = this.tableList;
      let newList = [];
      goodsList.forEach((item) => {
        if (this.no_sorting_printing) {
          newList.push(item.id);
        } else {
          if (item && item.status == 1) {
            newList.push(item.id);
          }
        }
      });
      this.$confirm(`系统将连续打印${newList.length}个商品，确定吗？`, "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(async () => {
          for (let index = 0; index < newList.length; index++) {
            const item = newList[index];
            await this.print(item);
          }
        })
        .catch(() => {});
    },
    // 打印
    print(id, num) {
      this.printid = id;
      return new Promise((resolve, reject) => {
        this.$refs.printTemplate.$emit("sortPrintNote", {
          data: {
            id: id,
            num: num,
          },
          cb: (res) => {
            resolve(res);
          },
        });
      });
    },
    // 撤销全部
    chexiaoAll() {
      let goodsList = this.tableList;
      let newList = [];
      goodsList.forEach((item) => {
        if (item && item.status == 1 && item.order.order_status == 1) {
          newList.push(item.id);
        }
      });
      this.$confirm(
        `系统将撤销${newList.length}个已分拣商品，确定吗？`,
        "提示",
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }
      )
        .then(() => {
          if (newList.length == 0) {
            this.$message.warning("没有需要操作的商品！");
            return;
          }
          let ids = newList.join("-");
          let data = Object.assign(
            {
              sign: Md5(
                objKeySort(Object.assign(apiUrl().name, { ids: ids })) +
                  apiUrl().appsecret
              ),
            },
            apiUrl().name,
            { ids: ids }
          );
          this.listLoading = true;
          revoke_list(data).then((res) => {
            if (res.errcode == 0) {
              this.$message.success("撤销成功");
              this.listLoading = false;
              // this.reload();
              this.getList();
            }
          });
        })
        .catch(() => {});
    },
    // 配送日期选择
    peisonDatePick() {
      this.getArticleList();
    },
    // 商户名称输入回车
    goodsnamePick() {
      this.getArticleList();
    },
    // 商户名称输入回车
    companynamePick() {
      this.getArticleList();
    },
  },
};
</script>
<style lang="scss" scoped>
@import "@/styles/variables.scss";

.mainor_form form {
  width: 100%;
}
.batch-wrap-right {
  display: flex;
  .el-checkbox {
    margin-right: 12px;
    flex: 20%;
  }
}
.batch-time-wrap {
  padding-top: 20px;
}
/deep/.el-progress-bar__innerText {
  transform: translateY(-1px);
}
.mainsa_bt {
  position: absolute;
  bottom: 20px;
  right: 0;
  z-index: 3;
  .el-button {
    border-color: $menuActiveText;
    color: $menuActiveText;
  }
}
// 分拣弹出窗
.addfenjian {
  /deep/ .el-input__inner {
    padding-right: 0 !important;
  }
  .add_num {
    font-size: 16px;
  }
}

// 当表格行选择的时候
/deep/.el-table .success {
  color: red;
  font-weight: 700;
  font-size: 20px;
}
.new_navbar_svg {
  vertical-align: top;
}
.status_box {
  width: 82px;
  text-align: right;
  position: absolute;
  top: 17px;
  left: -51px;
  span {
    margin: 0;
    padding: 0;
  }
}
/deep/.el-tag--mini {
  margin-right: 5px;
}
/deep/.main_table .el-table--small td .cell {
  display: flex;
}

/deep/.el-table td div {
  display: flex;
  align-items: center;
}
.label-pic {
  width: 16px;
  height: 20px;
  margin-right: 5px;
  margin-top: 4px;
}
.item-label {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
}

.item-label div {
  height: auto;
  padding: 4px 10px;
  border: 1px solid #e6a23c;
  color: #e6a23c;
  margin-bottom: 5px;
  border-radius: 3px;
  margin-right: 10px;
}
/deep/.el-input.is-disabled .el-input__inner {
  color: #666;
}
/deep/.el-dialog__body {
  padding: 0;
}
/deep/.set_header_sort {
  min-width: 200px;
}
/deep/.el-checkbox {
  flex: 30%;
}
/deep/.el-checkbox-group {
  display: flex;
  flex-wrap: wrap;
}

.boxd {
  position: absolute;
  top: 50px;
  right: 0;
}

/deep/ .el-form-item--small.el-form-item {
  margin-bottom: 10px !important;
}
.el-checkbox:last-of-type {
  margin-right: 30px;
}
</style>
